
# ecode doc: http://en.wikipedia.org/wiki/E_number

from google.appengine.ext import db
from google.appengine.ext.db import Model

class StringResourse(Model):
    #resource as key name(unique)
    pass

class LocalizedString(Model):
    local_code = db.StringProperty(required=True,
        choices=set(['en_us', 'ru_ru']))
    local_str  = db.StringProperty(required=True)
    str_res    = db.ReferenceProperty(StringResourse, required=True)

class Group(Model):
    #range as key name(unique)
    description = db.ReferenceProperty(StringResourse, required=True)
    update_time = db.DateTimeProperty(auto_now=True, auto_now_add=True)

class GroupByRange(Model):
    #range as key name(unique)
    description = db.ReferenceProperty(StringResourse, required=True)
    group       = db.ReferenceProperty(Group, required=True)
    update_time = db.DateTimeProperty(auto_now=True, auto_now_add=True)

class ENumber(Model):
    #code as key name(unique)
    range       = db.ReferenceProperty(GroupByRange  , required=True)
    name        = db.ReferenceProperty(StringResourse, required=True,
        collection_name='enum_name')
    category    = db.ReferenceProperty(StringResourse, required=True,
        collection_name='enum_category')
    side_effect = db.ReferenceProperty(StringResourse, required=True,
        collection_name='enum_side_effect')
    update_time = db.DateTimeProperty(auto_now=True, auto_now_add=True)
    